<template>
  <div class="cart_container">
    <div class="cart_wrapper">
      <div class="cart_header_container">购物清单</div>
      <div>
        <div class="cart_list_header">
          <div class="cart_list_header_wrapper">
            <div class="cart_item_info">商品信息</div>
            <div class="cart_header_item_container">
              <div>单价</div>
              <div>数量</div>
              <div>小计</div>
              <div>操作</div>
            </div>
          </div>
        </div>
        <div class="cart_list_container">
          <div class="cart_list_wrapper">
            <CartStore v-for="(item,index) in cartList"
            :key="index"
            :item="item"/>
          </div>
        </div>
      </div>
      <div class="cart_footer_container">
        <div>
          全选
          <input type="checkbox" :checked="allSelected"
          @click="onClickAllSelect"/>
        </div>
        <div>{{`总量${totalCount}`}}</div>
        <div>{{`总价${totalPrice}`}}</div>
        <div></div>
      </div>
    </div>
  </div>
</template>

<script>
import CartStore from "../components/CartStore";

export default {
  components:{
    CartStore
  },
  computed:{
    cartList:function(){
      // console.log(this.$store.state.cartModule.cartList);
      return this.$store.state.cartModule.cartList;
    },
    allSelected:function(){
      // console.log(this.$store.state.cartModule.allSelected);
      return this.$store.state.cartModule.allSelected;
    },
    totalCount:function(){
      return this.$store.getters['cartModule/totalCount'];
    },
    totalPrice:function(){
      return this.$store.getters["cartModule/totalPrice"];
    }
  },
  methods:{
    onClickAllSelect(event){
      var checked = event.target.checked;
      this.$store.commit("cartModule/CHANGE_ALL_SELECTED",checked);
    }
  }
}
</script>

<style scoped>
.cart_container
{
  width: 100%;
  height: 100vh;
  display: inline-flex;
  justify-content: center;
  align-items: flex-start;
  background-color: rgb(237, 237, 237);
}

.cart_wrapper
{
  width: 90%;
  height: 80vh;
  margin-top: 40px;
  position: relative;
  background-color: white;
}
.cart_header_container
{
  box-sizing: border-box;
  width: 100%;
  height: 8vh;
  background-color: rgb(201, 199, 199);
  display: inline-flex;
  justify-content: flex-start;
  align-items: center;
  /* margin-left: 40px; */
  padding-left: 30px;
}

.cart_footer_container
{
  width: 100%;
  height: 10vh;
  position: absolute;
  bottom: 0px;
  left: 0px;
  background-color: rgb(201, 199, 199);
}

.cart_list_header
{
  width: 100%;
  height: 6vh;
  background-color: rgb(201, 199, 199);
  border-top: 1px solid black;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.cart_list_header_wrapper
{
  width: 90%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.cart_item_info
{
  width: 50%;
  height: 100%;
  display: inline-flex;
  justify-content: flex-start;
  align-items: center;
}

.cart_header_item_container
{
  width: 50%;
  height: 100%;
  display: inline-flex;
  justify-content: flex-start;
  align-items: center;
  
}

.cart_header_item_container div
{
  flex: 1;
  height: 30px;
  border: 1px solid red;
}

.cart_list_container
{
  width: 100%;
  height: 56vh;
  border: 1px solid red;
  overflow: scroll;
}

.cart_list_wrapper
{
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}
</style>
